<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/html">

<head>
    <meta charset="UTF-8">
    <title>服务平台</title>
    <link href="__PUBLIC__/layui/css/layui.css" rel="stylesheet" />
</head>
<style>.custom-form-item {
    float: left;
    padding: 0 3px;
}</style>

<body>
<div class="admin-main">
    <blockquote class="layui-elem-quote">
        <form  class="layui-form"  action="">
            <div class="custom-form-item">
                <label class="layui-form-label">平台：</label>
                <div class="layui-input-inline">
                    <select name="siteid">
                        <option value="请选择">请选择</option>
                        <volist name=":C('ServerProvider')" id="vo">
                            <if condition="$vo['is_display']">
                            <option value="{$vo['val']}" <if condition="$_GET['siteid'] eq $vo['val']">selected</if>>{$key}</option>
                            </if>
                        </volist>
                    </select>
                </div>
            </div>
            <div class="custom-form-item">
                <label class="layui-form-label">主机状态：</label>
                <div class="layui-input-inline">
                    <input type="radio" name="pagestatus" value="1" title="开启" <if condition="$_GET['pagestatus'] eq 1">checked</if>>
                    <input type="radio" name="pagestatus" value="2" title="禁止" <if condition="$_GET['pagestatus'] eq 2">checked</if>>
                    <input type="radio" name="pagestatus" value="0" title="所有" <if condition="empty($_GET['pagestatus'])">checked</if>>
                </div>
            </div>
            <div class="custom-form-item">
                <button class="layui-btn layui-btn-small"  lay-submit="" lay-filter="searchtable">搜索</button>
            </div>
        </form>
        <div class="custom-form-item">
            <button  class="layui-btn layui-btn-small add">
                <i class="layui-icon">&#xe608;</i> 新增配置价格
            </button>
        </div>
        <div class="layui-clear"></div>
    </blockquote>
    <fieldset class="layui-elem-field">
        <legend>主机配置价格列表</legend>
        <div class="layui-field-box">
            <table class="layui-table">
                <thead>
                <tr>
                    <th>id</th>
                    <th>服务商</th>
                    <th>机房标牌</th>
                    <th>主机类型</th>
                    <th>主机型号</th>
                    <th>CPU/内存</th>
                    <th>状态</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody id="listcontent">
                </tbody>
            </table>
        </div>
    </fieldset>
    <div class="admin-table-page">
        <div id="page" class="page">
        </div>
    </div>
</div>
<script id="demo" type="text/html">
    <tr>
        <td>{{d.k}}</td>
        <td>{{d.sername}}</td>
        <td>{{d.url.regionsname}}-{{d.url.zonename}}</td>
        <td>{{d.url.describeTypes}}</td>
        <td>{{d.url.sdktype}}</td>
        <td>{{d.url.hostcpu }}核/{{ d.url.sdk}}</td>
        <td>
            {{# if(d.isstatus == 2){ }} <span>禁止</span> {{# }else if(d.isstatus == 1){ }} <span>开启</span> {{# } }}
        </td>
        <td>
            <a data="{{d.keyid}}" class="layui-btn layui-btn-mini layui-btn-normal edit"><i class="layui-icon">&#xe642;</i>修改状态</a>
          <!--  <a  data="{{d.keyid}}" class="layui-btn layui-btn-danger layui-btn-mini del"><i class="layui-icon">&#xe640;</i>删除</a>-->
        </td>
    </tr>
</script>
<script type="text/javascript" src="__PUBLIC__/layui/layui.js"></script>
<script>
    var form,layer,$,laytpl;
    var platfromPakeageaddurl="{:U('Service/platfromPakeageadd')}";
    layui.use(['layer', 'form','laypage','laytpl'], function () {
        var laypage = layui.laypage;
        laytpl = layui.laytpl;
        form = layui.form();
        $ = layui.jquery
        layer=layui.layer;
        var pagelistdate;
        var curr;

        laypage({
            cont: 'page',
            pages: parseInt('{$page}|default=1}') //总页数
            ,
            groups: 5 //连续显示分页数
            ,

            jump: function(obj, first) {
                curr = obj.curr;
                $('#listcontent').html('');
                $.ajax({
                    type: "GET",
                    url: "",
                    data: { p:curr},
                    async: false,
                    success: function(date){
                        if(date['code']==101) {
                            pagelistdate =date .data;
                            layui.each(date.data, function (k, v) {
                                v.k=k+1;
                                var getTpl = demo.innerHTML;
                                laytpl(getTpl).render(v, function (html) {
                                    listcontent.innerHTML += html;
                                });
                            });
                        }else{
                            listcontent.innerHTML='';
                        }
                    }
                });
                caozuo();
            }
        });

        form.on('submit(searchtable)', function(data){
           location.href='/index.php/Admin/Service/platfromPakeage.html?siteid='+data.field.siteid+'&pagestatus='+data.field.pagestatus;
            return false;
        });

        //location.href='http://www.xxxx.com';

        $('.add').click(function(){
            $.get(platfromPakeageaddurl,function(data){
                if(data.code == '4001'){
                    layer.msg(data.msg,{icon: 5});
                    return;
                }
                layer.open({
                    title:'添加平台套餐',
                    type: 1,
                    skin: 'layui-layer-rim',
                    area: ['700px','500px'],
                    content: data
                });
            });
        });

        function caozuo(){
            $('.edit').click(function () {
                var id = $(this).attr('data');
                $.get(platfromPakeageaddurl, {keyid: id}, function (data) {
                    if (data.code == '4001') {
                        layer.msg(data.msg, {icon: 5});
                    }
                    layer.open({
                        title: '修改主机配置状态',
                        type: 1,
                        skin: 'layui-layer-rim',
                        area: [ '500px;'],
                        content: data,
                    });
                });
            });

            $('.api').click(function(){
               // pagelistdate
                var id = $(this).attr('data');
                $html='<div class="layui-form-item"><label class="layui-form-label">cpu/内存：</label><div class="layui-input-block" style="padding: 9px 0px;">'+pagelistdate[id]['url']['hostcpu']+'核/'+pagelistdate[id]['url']['sdk']+' </div></div>';
               /* $html+='<div class="layui-form-item"><label class="layui-form-label">磁盘类型：</label><div class="layui-input-block" style="padding: 9px 0px;">'+pagelistdate[id]['url']['disktype']+'</div></div>';*/
                $html+='<div class="layui-form-item"><label class="layui-form-label">磁盘大小：</label><div class="layui-input-block" style="padding: 9px 0px;">'+pagelistdate[id]['url']['diskzero']+'GB</div></div>';
                layer.open({
                    type: 1,
                    title: false,
                    area: '516px',
                    closeBtn: 0,
                    shadeClose: true,
                    skin: 'yourclass',
                    content: $html
                });
            })
        }
    });
</script>
</body>

</html>